package com.sbr.seb.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

import com.sbr.seb.exception.Exceptionable;

@Aspect
public class ExceptionAspect {

	@Around("execution(* com.sbr..*.service.impl..* (..))")
	public Object execMethodeSM(final ProceedingJoinPoint pjp) throws Throwable {
		Object value = null;
		
		final Exceptionable sm = (Exceptionable) pjp.getTarget();

		try {
			sm.nettoyerErreursMetier();
			value = pjp.proceed();
			sm.remonterErreursMetier();
			
		} catch (final Throwable t) {
			throw t;
		}

		return value;
	}
}